<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../include/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>机构表单页面</title>
<%@ include file="../include/easyui.jsp"%>
</head>
<body>
<div>
	<form id="mainform" action="${ctx}/system/organization/${action}" method="post">
	<table  class="formTable">
		<tr>
			<td>机构名称：</td>
			<td>
                <c:if test="${action == 'update'}">
				    <input type="hidden" name="id" value="${organization.id }"/>
                </c:if>
				<input id="name" name="name" type="text" value="${organization.name }" class="easyui-validatebox" data-options="width: 180,required:'required',validType:'length[2,20]'"/>
			</td>
		</tr>
		<tr>
			<td>机构编码：</td>
			<td><input id="code" name="code" type="text" value="${organization.code }" class="easyui-validatebox"  data-options="width: 180,required:'required'" class="easyui-validatebox"/></td>
		</tr>
		<tr>
			<td>上级机构：</td>
			<td><input id="parentId" name="parentId" value="${organization.parentId }"/></td>
		</tr>
		<tr>
			<td>排序：</td>
			<td><input id="sort" type="text" name="sort" value="${organization.sort }" class="easyui-numberbox" data-options="width: 180" /></td>
		</tr>
	</table>
	</form>
</div> 
<script type="text/javascript">
//父级权限
var action="${action}";
if(action=='add'){
	$('#parentId').val(pid);
}else if(action=='update'){
	$('#parentId').val(pid);
}

//上级机构
$('#parentId').combotree({
	width:180,
	method:'GET',
    url: '${ctx}/system/organization/list',
    idField : 'id',
    textFiled : 'name',
	parentField : 'parentId',
	iconCls: 'icon',
    animate:true
});  

$('#mainform').form({    
    onSubmit: function(){    
    	var isValid = $(this).form('validate');
		return isValid;	// 返回false终止表单提交
    },    
    success:function(data){
        var data = eval('(' + data + ')');
    	if(successTip(data.message,dg,dialog)) {
			dg.treegrid('reload');
		}
    }    
});
</script>
</body>
</html>